﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EventumReports
{
    public partial class ChartRoll : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetImages();
        }

        private void GetImages()
        {
            
            string chartParth = Path.Combine(Server.MapPath("Charts"),
                                             DateTime.Now.Year + "_" + DateTime.Now.Month + "_" +
                                             DateTime.Now.Day + "_" + DateTime.Now.Hour);

            string[] fileEntries = Directory.GetFiles(chartParth);
            
            StringBuilder sb = new StringBuilder();
            bool set = false;
            foreach (string fileName in fileEntries)
            {
                FileInfo fi = new FileInfo(fileName);
                string filepath = Path.Combine(chartParth, fileName);

                if(!fi.Name.Contains("thumbs"))
                {
                    sb.Append("<a href=\"#\"");
                    if (!set)
                    {
                        sb.Append(" class=\"show\" ");
                        set = true;
                    }
                    sb.Append(" >");
                    sb.Append("<img src=\"" + "/Charts/" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "/" + fi.Name + "\"");
                    //sb.Append(" rel=\"<h3>Flowing Rock</h3>wohoo\"");
                    sb.Append(" rel=\"\"");
                    sb.Append(" /></a>\n");
                }
            }
            litImages.Text = sb.ToString();
        }
    }
}
